package com.qipay.admin.utils;

import org.apache.commons.lang3.StringUtils;

import javax.xml.crypto.Data;
import javax.xml.parsers.ParserConfigurationException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by 杨荔楠_pc on 2018/1/2.
 */
public class DateUtils {

    public  static final String yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss";

    public  static Date parse(String date, String format){
        Date resultDate =null;
        if(!StringUtils.isEmpty(date)){
            if(StringUtils.isEmpty(format)){
                format = yyyyMMddHHmmss;
            }
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
            try {
                resultDate  =   simpleDateFormat.parse(date);
            }catch (ParseException e){

            }
        }
       return resultDate;
    }
}
